﻿/******************************
 * Author：bly QQ:384607180
 * Date:2014-08-20 20:55:51
******************************/
using qcloudsms_csharp;
using System.IO;
using System.Net;
using System.Text;

namespace SDK.ApiService
{
    /// <summary>
    /// 短信服务
    /// </summary>
    public class SMSService
    {

        /// <summary>
        /// 接收人手机号
        /// </summary>
		private string phone { get; set; }

        /// <summary>
        /// 发送内容
        /// </summary>
		private string context { get; set; }

        /// <summary>
        /// 签名
        /// </summary>
		private string sign { get; set; }

        /// <summary>
        /// 短信模板 ID，需要在短信控制台中申请
        /// </summary>
        private int templateId { get; set; }


        /// <summary>
        /// 短信应用 SDK AppID
        /// </summary>
        int appid = 1400280565;

        /// <summary>
        /// 短信应用 SDK AppKey
        /// </summary>
        string appkey = "188a422a6a4a58bd6dd8dcf584245e43";

        


        /// <summary>
        /// 发送短信[寻程数据]
        /// </summary>
        /// <param name="va1">发送手机号</param>
        /// <param name="va2">发送内容</param>
        /// <param name="va3">发送签名</param>
        public SMSService(SMSParameter parameter) {
			this.phone = parameter.toPhone;
			this.context = parameter.context;
			this.sign = parameter.sign;
			this.templateId = parameter.templateId;
        }

        /// <summary>
        /// 发送
        /// </summary>
        /// <returns></returns>
        public SmsSingleSenderResult Send()
        {
            SmsSingleSender ssender = new SmsSingleSender(appid, appkey);

           return ssender.sendWithParam(
                "86", 
                phone,
                this.templateId, 
                new[] { this.context }, 
                this.sign, 
                string.Empty, 
                string.Empty);
        }

        
        
    }
}